import { AnimalDatas } from "../game/GameDefine";
cc.Class({
    extends: require('BasePanel'),

    properties: {
        nodContent: cc.Node,
        pfbItem: cc.Prefab,
    },
    onLoad() {
        this._super();

        this._addNodAnimal();
    },

    onEnter(args, action = true) {
        this._super(args, action);

    },

    onExit(args) {
        this._super(args);
    },

    _addNodAnimal() {
        let idx = 0;
        let tFunc = () => {
            let node = cc.instantiate(this.pfbItem);
            node.parent = this.nodContent;
            node.getComponent('ItemAnimalData').init(idx);
            idx++;
            if (idx >= AnimalDatas.length) {
                this.unschedule(tFunc);
            }
        }

        this.schedule(tFunc, 0.01);
    },

    show() {
        this._super();

    },

    hide(cb) {
        this._super(cb);
    },
    onEnable() {

    },
    onDisable() {
    },

    buttonListener: function (button) {
        G.game.gameAudioMgr.playBtn();
        let name = button.node.name;
        if (name == 'btnClose') {
            this.onClose();
        }
    },

    onTouchStart() {

    },
});
